PHP打印方法:
{php print_r(变量);}
<?php print_r(变量);?>
1.
{pc:get sql="select catname,url from v9_category order by listorder ASC" }{loop $data $r}
{ /pc} {php echo runhook('glogal_menu')}- { $r[catname]}
{ /loop}
加粗的写法:从栏目表查出catname 和 url字段值 按照listorder 正序排列
{pc:get sql="select catname,url from v9_category order by listorder ASC" } 可以改写成
{pc:get sql="select*from v9_category order by listorder ASC" }
2.导航选中状态:
{ if $catid == $r['catid']}class="current"{/if}
例如:
{pc:get sql="select * from v9_category order by listorder ASC" }{ if $catid}
{ /pc} {php echo runhook('glogal_menu')}- 首页
{ else}- 首页
{ /if} {loop $data $r}- { $r[catname]}
{ /loop}
当然首页那也可以这样:
$catid //当前栏目ID
$r['catid'] //循环出来的